﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace xycn.pluginsupport.BaseHelperPlugins
{
    /// <summary>
    /// 权限辅助类
    /// </summary>
    public static class DataCacheHelper
    {
        public static IDataCache.IDataCache cacheHelper = null;

        /// <summary>
        /// 添加权限插件接口
        /// </summary>
        /// <param name="name"></param>
        /// <param name="dbfactory"></param>
        /// <returns></returns>
        public static int Init(IPluginFactory.IPluginFactory logfactory)
        {
            if (logfactory == null)
                return -1;

            cacheHelper = (IDataCache.IDataCache)logfactory.CreatePlugin();
            return 0;
        }

        public static void DelCache(string key)
        {
            cacheHelper.DelCache(key);
        }

        public static T GetCache<T>(string key)
        {
            return cacheHelper.GetCache<T>(key);
        }

        public static dynamic GetCache(string key)
        {
            return cacheHelper.GetCache(key);
        }

        public static bool SetCache(string key, object value)
        {
            return cacheHelper.SetCache(key, value);
        }

        public static bool SetCache(string key, dynamic value, int minutes)
        {
            return cacheHelper.SetCache(key, value, minutes);
        }
    }
}
